home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_tut / vanilla.ada < prev    next >
Text File  |  1996-01-30  |  3KB  |  51 lines

  1. -- VANILLA.ADA   Ver. 3.00   22-AUG-1994   Copyright 1988-1994 John J. Herro
  2. -- Software Innovations Technology
  3. -- 1083 Mandarin Drive NE, Palm Bay, FL  32905-4706   (407)951-0233
  4. --
  5. -- "Plain vanilla" version of CUSTOM_IO which should work with ANY standard Ada
  6. -- compiler.  Compile this before compiling ADA_TUTR.ADA.
  7. --
  8. with Text_IO;
  9. package Custom_IO is
  10.    type Color is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White);
  11.    Foregrnd_Color   : Color := White;                 -- Default values in case
  12.    Backgrnd_Color   : Color := Black;                 -- ADA-TUTR finds no User
  13.    Border_Color     : Color := Black;                 -- File.
  14.    Fore_Color_Digit : Character := Character'Val(Color'Pos(Foregrnd_Color)+48);
  15.    Back_Color_Digit : Character := Character'Val(Color'Pos(Backgrnd_Color)+48);
  16.    Normal_Colors    : String(1 .. 10) := ASCII.ESC & "[0;3" &
  17.                               Fore_Color_Digit & ";4" & Back_Color_Digit & "m";
  18.    Clear_Scrn       : constant String := ASCII.ESC & "[H" & ASCII.ESC & "[2J";
  19.  
  20.    procedure Set_Border_Color (To   : in  Color);
  21.    procedure Get              (Char : out Character) renames Text_IO.Get;
  22.    procedure Put              (Char : in  Character) renames Text_IO.Put;
  23.    procedure Put              (Str  : in  String)    renames Text_IO.Put;
  24.    procedure Put_Line         (Str  : in  String)    renames Text_IO.Put_Line;
  25.    procedure Get_Line         (Str  : out String;
  26.                                Last : out Natural)   renames Text_IO.Get_Line;
  27.    procedure New_Line      (Spacing : in  Text_IO.Count := 1)
  28.                                                      renames Text_IO.New_Line;
  29. end Custom_IO;
  30.  
  31. package body Custom_IO is
  32.    procedure Set_Border_Color(To : in Color) is
  33.       --
  34.       -- This is a dummy procedure.  If your PC Ada compiler allows interrupt
  35.       -- calls or assembly language, you may want to write code to call
  36.       -- interrupt 10 hex.  (See JANUS.ADA and MERIDIAN.ADA for examples.)
  37.       -- Before the call, set register AH to service number 0B hex, set BH to
  38.       -- zero, and set BL to Color_Number(To), where Color_Number is declared
  39.       -- below.  Note that the integers in Color_Number are bit reversed from
  40.       -- the integers defining foreground and background colors in ANSI escape
  41.       -- sequences.  Note also that some color PCs don't have separate border
  42.       -- colors.
  43.       --
  44.       Color_Number : constant array(Color) of Integer :=
  45.           (Black   => 0,   Red     => 4,   Green   => 2,   Yellow  => 6,
  46.            Blue    => 1,   Magenta => 5,   Cyan    => 3,   White   => 7);
  47.    begin
  48.       null;
  49.    end Set_Border_Color;
  50. end Custom_IO;
  51.